package com.hf.job

import com.hf.init.InitService
import com.hf.security.MailOweMoneyReminderService
import com.hf.security.SystemConfigService

class OweMoneyReminderJob {

	MailOweMoneyReminderService mailOweMoneyReminderService
	SystemConfigService systemConfigService
	InitService initService

	static triggers = {
		// 13:45, last workday of period
		cron name: 'oweMoneyReminderJob', cronExpression: "0 45 13 ? * 1-7"
	}

	def execute() {
		if (systemConfigService.isBillDayOfPeriod()) {
			// execute job
			log.info "job run!"
	
			mailOweMoneyReminderService.sendMail()
			systemConfigService.setBillDayOfNextPeriod()
	
			log.info "owe money reminder email success"
		}
	}
}
